#ifndef MAP_H
#define MAP_H

#include <QMainWindow>

#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QKeyEvent>
#include "Lushanhu.h"
#include "longjiejing.h"
#include<QLabel>
#include"yideng.h"
#include"tedeng.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class Map;
}
QT_END_NAMESPACE

class Map : public QMainWindow
{
    Q_OBJECT

public:
    Map(QWidget *parent = nullptr);
    ~Map();


protected:
    void keyPressEvent(QKeyEvent *event) override;
    void keyReleaseEvent(QKeyEvent *event) override;
    void timerEvent(QTimerEvent *event) override;

private slots:
    void checkPositionAndInteract();

private:
    Ui::Map *ui;
    QGraphicsScene *scene;
    QGraphicsPixmapItem *character;
    QGraphicsPixmapItem *mapBackground;

    // 位置区域定义 (x, y, width, height)
    QRect lushanhu;//小写是地图区域 陆珊瑚
    QRect ljj;//龙结晶
    QRect yd;//一等小屋
    QRect td;//特等小屋

    //交互提示
    QLabel *interHint;

    // 移动控制
    bool moveUp = false;
    bool moveDown = false;
    bool moveLeft = false;
    bool moveRight = false;
    int moveSpeed = 5;

    // 其他窗口
    Lushanhu *lushanhu1;//1是对象
    longjiejing *longjiejing1;
    tedeng *tedeng1;
    yideng *yideng1;


    void setupMap();
    void setupCharacter();
    void setupLocations();
    void enterLocation(int location);
    void charAnimations();
    void updateAnimation();



    // 角色动画相关
    enum Direction {Down, Left, Right };
    Direction currentDirection = Down;
    int currentFrame = 0;
    QTimer *animationTimer;
    QMap<Direction, QVector<QPixmap>> animationFrames;

    //
};
#endif // MAP_H
